const EventEmitter = require('events');
const util = require('util');

function MyEmitter() {
    EventEmitter.call(this);
}
util.inherits(MyEmitter, EventEmitter);

const myEmitter = new MyEmitter();

process.on('uncaughtException', (err) => {
    console.log('Uncaught exception in process.');
    console.error(err);
});

myEmitter.on('error', (err) => {
    console.log('Exception in emitter.');
    console.error(err);
})

myEmitter.emit('error', new Error('whoops!'));
